<template>
  <div>
    <el-container>
      <el-header>&nbsp;人力资源管理系统</el-header>
      <el-container class="container">
        <el-aside width="300px">
          <Menu>

          </Menu>
        </el-aside>
        <el-container>
          <el-main>
            <el-row>
              <el-col :span="22">
                <div class="grid-content bg-purple-dark">
                  薪酬发放复核
                </div>
              </el-col>
              <el-col :span="2">
                <div class="grid-content">
                  <el-button type="success" round @click="review">复核通过</el-button>
                </div>
              </el-col>
            </el-row>
            <el-row>
              <el-col :span="4">
                <div class="grid-content bg-purple">
                  <span>
                    薪酬发放单编号
                  </span>
                </div>
              </el-col>
              <el-col :span="4">
                <div class="grid-content bg-purple-light">
                  {{salaryDistributionFile.slistId}}
                </div>
              </el-col>
              <el-col :span="4">
                <div class="grid-content bg-purple">
                  <span>
                    登记人
                  </span>
                </div>
              </el-col>
              <el-col :span="4">
                <div class="grid-content bg-purple-light">
                  <el-input v-model="salaryDistributionFile.registrant" disabled/>
                </div>
              </el-col>
              <el-col :span="4">
                <div class="grid-content bg-purple">
                  <span>
                    登记日期
                  </span>
                </div>
              </el-col>
              <el-col :span="4">
                <div class="grid-content bg-purple-light">
                  <el-input v-model="salaryDistributionFile.registerTime" disabled placeholder="系统自动填写"/>
                </div>
              </el-col>
            </el-row>
            <el-row>
              <el-col :span="4">
                <div class="grid-content bg-purple">
                  <span>
                    I级机构
                  </span>
                </div>
              </el-col>
              <el-col :span="4">
                <div class="grid-content bg-purple-light">
                  <el-select v-model="salaryDistributionFile.forgId" disabled placeholder="请选择" style="width: 100%">
                    <el-option
                        v-for="item in salaryDistribution.FirstOrganization"
                        :key="salaryDistributionFile.forgId"
                        :label="item.forgName"
                        :value="item.forgId"
                    >
                    </el-option>
                  </el-select>
                </div>
              </el-col>
              <el-col :span="4">
                <div class="grid-content bg-purple">
                  <span>
                    II级机构
                  </span>
                </div>
              </el-col>
              <el-col :span="4">
                <div class="grid-content bg-purple-light">
                  <el-select v-model="salaryDistributionFile.sorgId" disabled placeholder="请选择" style="width: 100%">
                    <el-option
                        v-for="item in salaryDistribution.SecondOrganization"
                        :key="salaryDistributionFile.sorgId"
                        :label="item.sorgName"
                        :value="item.sorgId"
                    >
                    </el-option>
                  </el-select>
                </div>
              </el-col>
              <el-col :span="4">
                <div class="grid-content bg-purple">
                  <span>
                    III级机构
                  </span>
                </div>
              </el-col>
              <el-col :span="4">
                <div class="grid-content bg-purple-light">
                  <el-select v-model="salaryDistributionFile.torgId" disabled placeholder="请选择" style="width: 100%">
                    <el-option
                        v-for="item in salaryDistribution.ThirdOrganization"
                        :key="salaryDistributionFile.torgId"
                        :label="item.torgName"
                        :value="item.torgId"
                    >
                    </el-option>
                  </el-select>
                </div>
              </el-col>
            </el-row>
            <el-row>
              <el-col :span="2">
                <div class="grid-content bg-purple">
                  <span>
                    档案编号
                  </span>
                </div>
              </el-col>
              <el-col :span="2">
                <div class="grid-content bg-purple-light">
                  <span>
                    姓名
                  </span>
                </div>
              </el-col>
              <el-col :span="2">
                <div class="grid-content bg-purple">
                  <span>
                    基本工资
                  </span>
                </div>
              </el-col>
              <el-col :span="2">
                <div class="grid-content bg-purple-light">
                  <span>
                    交通补助
                  </span>
                </div>
              </el-col>
              <el-col :span="2">
                <div class="grid-content bg-purple">
                  <span>
                    午餐补助
                  </span>
                </div>
              </el-col>
              <el-col :span="2">
                <div class="grid-content bg-purple-light">
                  <span>
                    通勤补助
                  </span>
                </div>
              </el-col>
              <el-col :span="2">
                <div class="grid-content bg-purple">
                  <span>
                    养老保险
                  </span>
                </div>
              </el-col>
              <el-col :span="2">
                <div class="grid-content bg-purple-light">
                  <span>
                    失业保险
                  </span>
                </div>
              </el-col>
              <el-col :span="2">
                <div class="grid-content bg-purple">
                  <span>
                    医疗保险
                  </span>
                </div>
              </el-col>
              <el-col :span="2">
                <div class="grid-content bg-purple-light">
                  <span>
                    住房公积金
                  </span>
                </div>
              </el-col>
              <el-col :span="2">
                <div class="grid-content bg-purple">
                  <span>
                    奖励金
                  </span>
                </div>
              </el-col>
              <el-col :span="2">
                <div class="grid-content bg-purple-light">
                  <span>
                    扣除金
                  </span>
                </div>
              </el-col>
            </el-row>
            <el-row
                :model="salaryDistributionDetailFile"
                placement="top"
                v-for="salaryDistributionDetail in salaryDistributionDetail">
              <el-col :span="2">
                <div class="grid-content bg-purple">
                  <span>
                    {{salaryDistributionDetail.fileId}}
                  </span>
                </div>
              </el-col>
              <el-col :span="2">
                <div class="grid-content bg-purple-light">
                  <span>
                    {{salaryDistributionDetail.name}}
                  </span>
                </div>
              </el-col>
              <el-col :span="2">
                <div class="grid-content bg-purple">
                  <span>
                    {{salaryDistributionDetail.basic}}
                  </span>
                </div>
              </el-col>
              <el-col :span="2">
                <div class="grid-content bg-purple-light">
                  <span>
                    {{salaryDistributionDetail.transportation}}
                  </span>
                </div>
              </el-col>
              <el-col :span="2">
                <div class="grid-content bg-purple">
                  <span>
                    {{salaryDistributionDetail.lunch}}
                  </span>
                </div>
              </el-col>
              <el-col :span="2">
                <div class="grid-content bg-purple-light">
                  <span>
                    {{salaryDistributionDetail.communication}}
                  </span>
                </div>
              </el-col>
              <el-col :span="2">
                <div class="grid-content bg-purple">
                  <span>
                    {{salaryDistributionDetail.endowment}}
                  </span>
                </div>
              </el-col>
              <el-col :span="2">
                <div class="grid-content bg-purple-light">
                  <span>
                    {{salaryDistributionDetail.unemployment}}
                  </span>
                </div>
              </el-col>
              <el-col :span="2">
                <div class="grid-content bg-purple">
                  <span>
                    {{salaryDistributionDetail.medical}}
                  </span>
                </div>
              </el-col>
              <el-col :span="2">
                <div class="grid-content bg-purple-light">
                  <span>
                    {{salaryDistributionDetail.providentFund}}
                  </span>
                </div>
              </el-col>
              <el-col :span="2">
                <div class="grid-content bg-purple">
                  <span>
                    {{salaryDistributionDetail.bounty}}
                  </span>
                </div>
              </el-col>
              <el-col :span="2">
                <div class="grid-content bg-purple-light">
                  <span>
                    {{salaryDistributionDetail.deduction}}
                  </span>
                </div>
              </el-col>
            </el-row>
          </el-main>
        </el-container>
      </el-container>
    </el-container>
  </div>
</template>

<script>
import{ defineComponent, ref }from 'vue'
import {
  Location,
  Document,
  Menu as IconMenu,
  Setting,
} from '@element-plus/icons-vue'
import Menu from "@/components/Menu";
export default defineComponent({
  name: "SalaryDistributionRegistrationDetail",
  components: {
    Menu,
    Location,
    Document,
    Setting,
    IconMenu,
  },
  data() {
    return {
      salaryDistributionFile: {
        slistId: '',
        forgId: '',
        sorgId: '',
        torgId: '',
        registrant: '',
        registerTime: '',
      },
      salaryDistributionDetailFile: {
        fileId: '',
        name: '',

      },
      salaryDistribution: {
        FirstOrganization: null,
        forgName: null,
        forgId: null,
        SecondOrganization: null,
        sorgName: null,
        sorgId: null,
        ThirdOrganization: null,
        torgName: null,
        torgId: null,
      },
      salaryDistributionDetail: {
        fileId: '',
        name: '',
        basic: '',
        transportation: '',
        lunch: '',
        communication: '',
        endowment: '',
        unemployment: '',
        medical: '',
        providentFund: '',
        bounty:'',
        deduction:'',
      }
    }
  },
  setup() {
    const activeNames = ref(['1'])
    const handleChange = (val) => {
      console.log(val)
    }
    return {
      activeNames,
      handleChange,
    }
  },
  methods: {
    getFirstOrg() {
      this.axios.get('/selectFirstOrg').then(res =>{
        const _this = this
        _this.salaryDistribution.FirstOrganization = res.data.data
      }).then(res =>{
        this.getSecondOrg()
      })
    },
    getSecondOrg() {
      this.axios.get('/selectSecondOrg/'+ this.salaryDistributionFile.forgId).then(res =>{
        const _this = this
        _this.salaryDistribution.SecondOrganization = res.data.data
      }).then(res =>{
        this.getThirdOrg()
      })
    },
    getThirdOrg() {
      this.axios.get('/selectThirdOrg/'+ this.salaryDistributionFile.sorgId).then(res =>{
        const _this = this
        _this.salaryDistribution.ThirdOrganization = res.data.data
      })
    },
    review() {
      this.axios.post('/ReviewSalary/' + this.salaryDistributionFile.slistId).then(res =>{
        alert("发放成功！")
        this.$router.push("/SalaryDistributionReview")
      })
    }
  },
  created() {
    const slistId = this.$route.params.slistId
    const _this = this
    if(slistId){
      this.axios.get('/SalaryDistributionReview/' + slistId).then(res =>{
        const salaryDistribution = res.data.data
        _this.salaryDistributionFile.slistId = salaryDistribution.slistId
        _this.salaryDistributionFile.forgId = salaryDistribution.forgId
        _this.salaryDistributionFile.sorgId = salaryDistribution.sorgId
        _this.salaryDistributionFile.torgId = salaryDistribution.torgId
        _this.salaryDistributionFile.registrant=salaryDistribution.registrant
      }).then(res =>{
        this.getFirstOrg()
      })
    }
    if(slistId){
      this.axios.get('/SalaryDistributionReviewListDetail/' + slistId).then(res =>{
        _this.salaryDistributionDetail = res.data.data
      })
    }
  },

})
</script>

<style scoped>
.el-header{
  background-color: #409EFF;
  color: #e9eef3;
  text-align: left;
  line-height: 60px;
  font-size: 30px;
}
.el-aside {
  background-color: #d3dce6;
  color: var(--el-text-color-primary);
  text-align: center;
  /*line-height: 860px;*/
}

.el-main {
  background-color: #e9eef3;
  color: var(--el-text-color-primary);
  text-align: center;
  line-height: 30px;
}

body > .el-container {
  margin-bottom: 400px;
}

.el-container:nth-child(5) .el-aside,
.el-container:nth-child(6) .el-aside {
  line-height: 260px;
}

.el-container:nth-child(7) .el-aside {
  line-height: 320px;
}

.el-row {
  margin-bottom: 20px;
}

.el-row :last-child {
  margin-bottom: 0;
}

.el-col {
  border-radius: 4px;
}
.bg-purple-dark {
  background: #99a9bf;
}
.bg-purple {
  background: #d3dce6;
}
.bg-purple-light {
  background: #e5e9f2;
}
.grid-content {
  border-radius: 4px;
  min-height: 36px;
}
.row-bg {
  padding: 10px 0;
  background-color: #f9fafc;
}

.high-row{
  min-height: 200px;
}

.container{
  min-height: 860px;
}

.line {
  width: 70%;
}

.line div {
  width: 100%;
  height: 0;
  border-top: 1px solid var(--el-border-color-base);
}

</style>